// Only compile lib targets for dependencies
let targets = dep.get_targets().iter().filter(|target| {
- target.is_lib() && target.get_profile().get_env() == env
+ target.is_lib() && match env {
+ "test" => target.get_profile().is_compile(),
+ _ => target.get_profile().get_env() == env,
+ }
}).collect::<Vec<&Target>>();
jobs.push((dep, try!(compile(targets.as_slice(), dep, &mut cx))));
fn compile(targets: &[&Target], pkg: &Package,
cx: &mut Context) -> CargoResult<(Freshness, Job)> {
- debug!("compile_pkg; pkg={}; targets={}", pkg, pkg.get_targets());
+ debug!("compile_pkg; pkg={}; targets={}", pkg, targets);
if targets.is_empty() {
return Ok((Fresh, proc() Ok(())))
})
test!(test_with_deep_lib_dep {
- let p = project("foo")
+ let p = project("bar")
.file("Cargo.toml", r#"
- [project]
+ [package]
name = "bar"
version = "0.0.1"
authors = []
[dependencies.foo]
- path = "foo"
+ path = "../foo"
"#)
.file("src/lib.rs", "
extern crate foo;
- pub fn bar() {}
- ")
+ #[test]
+ fn bar_test() {
+ foo::foo();
+ }
+ ");
+ let p2 = project("foo")
.file("Cargo.toml", r#"
- [project]
+ [package]
name = "foo"
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "
+ pub fn foo() {}
- assert_that(p.cargo_process("cargo-test"), execs().with_status(0));
+ #[test]
+ fn foo_test() {}
+ ");
+
+ p2.build();
+ assert_that(p.cargo_process("cargo-test"),
+ execs().with_status(0)
+ .with_stdout(format!("\
+{compiling} foo v0.0.1 (file:{dir})
+{compiling} bar v0.0.1 (file:{dir})
+
+running 1 test
+test bar_test ... ok
+
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n\
+ ",
+ compiling = COMPILING,
+ dir = p.root().display()).as_slice()));
})